<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>客户信息</title>
		<link rel="stylesheet" type="text/css" href="${BASE_PATH}/static/lib/layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="${BASE_PATH}/static/css/money.css" />
		<link rel="stylesheet" href="${BASE_PATH}/static/css/zoomify.min.css">
	</head>

	<style type="text/css">
		.layui-table-view {
			margin: 0px 10px 10px 10px;
		}
		
		.layui-input-block input {
			color: #000000;
		}
		
		.layui-upload-img {
			width: 92px;
			height: 92px;
			margin: 0 10px 10px 0;
		}
		
		.layui-elem-quote {
			margin-bottom: 0px;
		}
	</style>

	<body>
		<form class="layui-form  layui-form-pane" action="" style="margin: 10px 10px 0 10px;">
			<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
				<legend>基本信息</legend>
			</fieldset>
			<input id="yhUserId" name="yhUserId" value="${user.yhUserId}" type="hidden" />
			<div class="layui-form-item">
				<label class="layui-form-label">姓名</label>
				<div class="layui-input-inline">
					<input type="text" name="text" lay-verify="name" value="${user.yhUserName}" placeholder="" autocomplete="off" class="layui-input">
				</div>
				<label class="layui-form-label">身份证号</label>
				<div class="layui-input-inline">
					<input type="text" name="text" lay-verify="userName" value="${user.yhUserIdcard}" placeholder="" autocomplete="off" class="layui-input">
				</div>
				<label class="layui-form-label">电话号码</label>
				<div class="layui-input-inline">
					<input type="text" name="text" lay-verify="state" value="${user.yhUserPhone}" placeholder="" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">家庭详细地址</label>
				<div class="layui-input-inline" style="width: 499px;">
					<input type="text" name="text" lay-verify="name" value="${user.yhUserAdds}" placeholder="" autocomplete="off" class="layui-input">
				</div>
				<label class="layui-form-label">业务负责人</label>
				<div class="layui-input-inline">
					<input type="text" name="text" lay-verify="name" value="${user.userName}" placeholder="" autocomplete="off" class="layui-input">
				</div>
			</div>
		</form>
		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			<legend>贷款数据</legend>
		</fieldset>
		<table class="layui-table" lay-filter="test" lay-data="{url:'${BASE_PATH}/admin/user/ajax_user_loan_list?yhUserId=${user.yhUserId}', cellMinWidth: 80}">
			<thead>
				<tr>
					<th lay-data="{field:'loanMoney', width:120}" rowspan="3">贷款金额</th>
					<th lay-data="{field:'loanTypeName', width:120}" rowspan="3">贷款类别</th>
					<th lay-data="{field:'contractMoney', width:120}" rowspan="3">合同金额</th>
					<th lay-data="{field:'homeVisitsMoney', width:120}" rowspan="3">家访金额</th>
					<th lay-data="{field:'intermediary', width:120}" rowspan="3">中介金额</th>
					<th lay-data="{field:'bond', width:120}" rowspan="3">保证金</th>
					<th lay-data="{field:'actualMoney', width:120}" rowspan="3">实际到款金额</th>
					<th lay-data="{field:'stillMoney', width:120}" rowspan="3">实际还款金额</th>
					<th lay-data="{field:'collectMoney', width:120}" rowspan="3">实际收款金额</th>
					<th lay-data="{field:'alreadyRepaid', width:120}" rowspan="3">已还金额</th>
					<th lay-data="{field:'notYet', width:120}" rowspan="3">未还金额</th>
					<th lay-data="{fixed: 'right', width: 160, align: 'center', toolbar: '#barDemo'}" rowspan="3">操作</th>
				</tr>
			</thead>
		</table>
	</body>
	<script type="text/html" id="barDemo">
		<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="user_info">收款</a>
	</script>
	<script src="${BASE_PATH}/static/lib/layui/layui.js"></script>
	<script type="text/javascript" src="${BASE_PATH}/static/js/jquery-3.1.1.min.js"></script>
	<script>
		layui.use(['form', 'layedit', 'laydate', 'jquery', 'table', 'upload'], function() {
			var form = layui.form,
				layer = layui.layer;
			var $ = layui.jquery;
			var table = layui.table;
			var laydate = layui.laydate;
			var upload = layui.upload;

			laydate.render({
				elem: '#test19'
			});
			

			//逾期天数失焦
			$("#day").on("blur", function() {
				var yhUserId = $("#yhUserId").val();
				var day = $("#day").val();
				var m = $("#m").val();
				$.ajax({
					type: 'POST',
					url: '${BASE_PATH}/admin/user/ajax_user_over_day',
					data: {
						tyUserId: yhUserId,
						day: day
					},
					success: function(res) {
						if(res.success == true) {
							//alert(res.msg)
							//console.dir(res.t.dayMoney)
							$("#dayMoney").val(res.t.dayMoney);
							var sum = parseFloat(res.t.dayMoney) + parseFloat(m);
							$("#money").val(sum)
						}
					}
				})
			});

			//多图片上传
			upload.render({
				elem: '#test2',
				url: '${BASE_PATH}/admin/user/photo.json',
				multiple: false,
				number: 3,
				done: function(res) {
					if(res.success == true) {
						if($("#file").val() == "") {
							$("#file").val(res.t);
							$('#demo2').append('<img src="${BASE_PATH}/' + res.t + '" class="layui-upload-img">');
							console.dir("第一张照片上传成功")
						} else if($("#file1").val() == "") {
							$("#file1").val(res.t);
							$('#demo2').append('<img src="${BASE_PATH}/' + res.t + '" class="layui-upload-img">');
							console.dir("第二张上传成功")
						} else if($("#file2").val() == "") {
							$("#file2").val(res.t);
							$('#demo2').append('<img src="${BASE_PATH}/' + res.t + '" class="layui-upload-img">');
							console.dir("第三张照片上传成功")
						} else {
							layer.msg("对不起，只允许上传三张照片")
						}
					}
				}
			});
			
			var yetList = null;
			console.dir(yetList)
			
			
			
			//监听工具条
			table.on('tool(test)', function(obj) {
				var data = obj.data;
				var layEvent = obj.event;
				var tr = obj.tr;
				console.dir()

				if(layEvent === 'user_info') {
					layer.open({
						type: 2,
						content: 'money_info.htm?yhUserId=' + data.tyUserId + '&loanId=' + data.loanId,
						area: ['882px', '700px']
					});
				} 
			});

			//监听提交
			form.on('submit(demo1)', function(data) {
				$.ajax({
					type:'POST',
					url:'${BASE_PATH}/admin/user/ajax_update_money',
					data:data.field,
					success:function(res){
						if(res.success == true){
							layer.msg("完成收款")
							location.replace(location.href);
						}
					}
				})
				return false;
			});
		});
	</script>

	<script>
		var $a = $(".buttons a");
		var $s = $(".buttons span");
		var cArr = [
				[#list list as a]
				'${a.p}', [/#list]];
					var index = 0;

					$(".next").click(
						function() {
							previmg();
						}
					)
					$(".prev").click(
						function() {
							nextimg();
						}
					)
					//上一张
					function previmg() {
						cArr.unshift(cArr[${count} - 1]);
						cArr.pop();
						//i是元素的索引，从0开始
						//e为当前处理的元素
						//each循环，当前处理的元素移除所有的class，然后添加数组索引i的class
						$("li").each(function(i, e) {
							$(e).removeClass().addClass(cArr[i]);
						})
						index--;
						if(index < 0) {
							index = ${count} - 1;
						}
						//show();
					}

					//下一张
					function nextimg() {
						cArr.push(cArr[0]);
						console.dir(cArr[0])
						cArr.shift();
						$("li").each(function(i, e) {
							console.dir(i)
							//console.dir(e)
							$(e).removeClass().addClass(cArr[i]);
						})
						index++;
						if(index > 6) {
							index = 0;
						}
						//show();
					}
	</script>
	<script src="${BASE_PATH}/static/js/zoomify.min.js"></script>
	<script type="text/javascript">
		$('.example img').zoomify();
	</script>

</html>